/**
 * 
 */
package com.yidu.erp.service.wareType;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.common.SsmMessage;
import com.yidu.erp.dao.BeyondWaretypeMapper;
import com.yidu.erp.model.BeyondWaretype;

/**
 * 类的描述：药品种类service的实现类
 * @author xym
 *
 * @date 2017年11月25日
 */
@Service
public class WareTypeServiceImpl implements WareTypeService{
	@Resource
	BeyondWaretypeMapper wareType;
	public Map<String, Object> showAll(Map<String, Object> param){
		Map<String, Object> result=new HashMap<String,Object>();
		result.put("data", wareType.showAll(param));
		result.put("code", 0);
		result.put("msg", 0);
		result.put("count", wareType.findCount(param));
		return result;
	}
	public SsmMessage update(BeyondWaretype type){
		int row=wareType.updateByPrimaryKeySelective(type);
		SsmMessage mes=new SsmMessage();
		if(row>0){
			mes.setMes(SsmMessage.SUCCESS_MES);
			mes.setState(SsmMessage.SUCCESS);
		}else{
			mes.setMes(SsmMessage.ERROR_MES);
			mes.setState(SsmMessage.ERROR);
		}
		return mes;
	}
	public SsmMessage insert(BeyondWaretype type){
		int row=wareType.insertSelective(type);
		SsmMessage mes=new SsmMessage();
		if(row>0){
			mes.setMes(SsmMessage.SUCCESS_MES);
			mes.setState(SsmMessage.SUCCESS);
		}else{
			mes.setMes(SsmMessage.ERROR_MES);
			mes.setState(SsmMessage.ERROR);
		}
		return mes;
	}
	public SsmMessage delete(BeyondWaretype type){
		type.setIsva("0");
		int row=wareType.updateByPrimaryKeySelective(type); 
		SsmMessage mes=new SsmMessage();
		if(row>0){
			mes.setMes(SsmMessage.SUCCESS_MES);
			mes.setState(SsmMessage.SUCCESS);
		}else{
			mes.setMes(SsmMessage.ERROR_MES);
			mes.setState(SsmMessage.ERROR);
		}
		return mes;
	}
	/* (non-Javadoc)
	 * @see com.yidu.erp.service.wareType.WareTypeService#findById(java.lang.String)
	 */
	@Override
	public BeyondWaretype findById(String typeId) {
		return wareType.findById(typeId); 
	}
	
}
